<!-- views/sales/components/CustomerFilter.vue -->
<template>
  <el-card class="filter-card" shadow="never">
    <el-form :model="queryParams" inline>
      <el-form-item label="客户名称">
        <el-input
          v-model="queryParams.name"
          placeholder="输入客户名称"
          clearable
          style="width: 200px"
        />
      </el-form-item>
      
      <el-form-item label="联系人">
        <el-input
          v-model="queryParams.contactPerson"
          placeholder="输入联系人"
          clearable
          style="width: 150px"
        />
      </el-form-item>
      
      <el-form-item label="状态">
        <el-select v-model="queryParams.status" clearable placeholder="全部状态" style="width: 120px">
          <el-option label="启用" value="1" />
          <el-option label="禁用" value="0" />
        </el-select>
      </el-form-item>
      
      <el-form-item>
        <el-button type="primary" :icon="Search" @click="handleSearch">
          查询
        </el-button>
        <el-button :icon="Refresh" @click="handleReset">
          重置
        </el-button>
        <el-button 
          link
          :icon="SetUp" 
          @click="showAdvancedFilter = !showAdvancedFilter"
        >
          高级筛选
        </el-button>
      </el-form-item>
    </el-form>

    <!-- 高级筛选 -->
    <el-collapse-transition>
      <div v-show="showAdvancedFilter" class="advanced-filter">
        <el-divider content-position="left">高级筛选</el-divider>
        <el-form :model="queryParams" inline>
          <el-form-item label="电话">
            <el-input
              v-model="queryParams.phone"
              placeholder="输入电话"
              clearable
              style="width: 150px"
            />
          </el-form-item>
          
          <el-form-item label="邮箱">
            <el-input
              v-model="queryParams.email"
              placeholder="输入邮箱"
              clearable
              style="width: 200px"
            />
          </el-form-item>
        </el-form>
      </div>
    </el-collapse-transition>
  </el-card>
</template>

<script setup lang="ts">
import { ref, defineProps, defineEmits } from 'vue'
import { Search, Refresh, SetUp } from '@element-plus/icons-vue'

const showAdvancedFilter = ref(false)

// 地区选项数据
const regionOptions = [
  {
    value: 'zhejiang',
    label: '浙江省',
    children: [
      {
        value: 'hangzhou',
        label: '杭州市',
        children: [
          { value: 'xihu', label: '西湖区' },
          { value: 'binjiang', label: '滨江区' }
        ]
      }
    ]
  }
]

// 定义查询参数接口
interface QueryParams {
  name: string
  contactPerson: string
  phone: string
  email: string
  status: string
  page: number
  limit: number
}

const props = defineProps<{
  queryParams: QueryParams
}>()

const emit = defineEmits<{
  (e: 'search'): void
  (e: 'reset'): void
}>()

const handleSearch = () => {
  emit('search')
}

const handleReset = () => {
  emit('reset')
}
</script>

<style scoped>
.filter-card {
  margin-bottom: 20px;
}

.advanced-filter {
  margin-top: 16px;
}

.advanced-filter :deep(.el-divider) {
  margin: 16px 0;
}

.separator {
  margin: 0 8px;
  color: #c0c4cc;
}
</style>